package sixth.抽象类与接口的应用.抽象类的实际应用;

abstract class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.setAge(age);
        this.setName(name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void say() {
        System.out.println(getContent());
    }

    public abstract String getContent();
}

class Student extends Person {
    private float score;

    public Student(String name, int age, float score) {
        super(name, age);
        this.score = score;
    }

    public float getScore() {
        return score;
    }

    public void setScore(float score) {
        this.score = score;
    }

    public String getContent() {
        return "name:" + getName() + ",age:" + getAge() + ",score:" + getScore();
    }
}

class Worker extends Person {
    private float salary;

    public Worker(String name, int age, float salary) {
        super(name, age);
        this.salary = salary;
    }


    public float getSalary() {
        return salary;
    }

    public void setSalary(float salary) {
        this.salary = salary;
    }

    public String getContent() {
        return "name:" + getName() + ",age:" + getAge() + ",salary:" + getSalary();
    }
}

public class 抽象类的实际应用 {
    public static void main(String[] args) {
        Person student = new Student("张一三", 18, 22.2f);
        Person worker = new Worker("刘能", 19, 99.99f);
        student.say();
        worker.say();
    }
}
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=49610:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 sixth.抽象类与接口的应用.抽象类的实际应用.抽象类的实际应用
name:张一三,age:18,score:22.2
name:刘能,age:19,salary:99.99

Process finished with exit code 0

 */
